﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace xKnight.Models
{
    public static class EntityExtension
    {
        public static string GetId(this Form form)
        {
            string formAction = form.Action;

            //remove GET params from action
            if (formAction.Contains("?"))
            {
                int index = formAction.IndexOf("?");
                formAction = formAction.Substring(0, index);
            }

            string id = formAction + ":" + form.Method;
           
            /*
            for (int j = 0; j < form.FormElements.Count; j++)
            {
                id += ":" + form.FormElements.ElementAt(j).Name + ":" + form.FormElements.ElementAt(j).Value;
            }
             */

            return id.ToLower();
        }
    }
}